package com.surge;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.surge.controller.UserController;
import com.surge.respository.UserRepository;
import com.surge.service.UserService;

public class SurgeMain {

	private static ApplicationContext ctx;

	public static void main(String[] args) {
		
		
		// 创建 Spring 的 IOC 容器
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		
		/*
		 *  @Component: 基本注解, 标识了一个受 Spring 管理的组件
			@Respository: 标识持久层组件
			@Service: 标识服务层(业务层)组件
			@Controller: 标识表现层组件

		 */
		
		/*
		 * 1、注解使用,不需要在xml中配置userController等。。
		 */
		UserController userController =  (UserController) ctx.getBean("userController");
		System.out.println(userController);

		
		UserService userServiceImpl =  (UserService) ctx.getBean("userServiceImpl");
		System.out.println(userServiceImpl);
		

		UserRepository userRepositoryImpl =  (UserRepository) ctx.getBean("userRepositoryImpl");
		System.out.println(userRepositoryImpl);
		
	}

}
